package com.koron.css2.serviceManage.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserFieldBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.mapper.UserFieldConfigMapper;
import com.koron.util.Constant;
import com.koron.util.JsonUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;
/**
 * 用戶字段配置详情
 * @author 甄玉晴
 *
 */
public class UserFieldConfigQuery  implements ServerInterface{
	
	private static Logger logger = LogManager.getLogger(UserFieldConfigQuery.class);

	@Override
	public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
		
		MessageBean<UserFieldBean> info = MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "success", UserFieldBean.class);
		try {	
			UserFieldBean bean = JsonUtils.objectToPojo(req.getData(), UserFieldBean.class);
			//获取mapper
			UserFieldConfigMapper mapper = factory.getMapper(UserFieldConfigMapper.class);
			UserFieldBean  query=mapper.findUserFieldConfigById(bean.getId());
			info.setData(query);
		} catch (Exception e) {
			info.setCode(Constant.MESSAGE_INT_FAIL);
			info.setDescription(e.getMessage());
			logger.error(e.getMessage(), e);
		}
		return info;
	}


}
